<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="
viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script>
        // 拦截器
        //请求拦截
        axios.interceptors.request.use(config => {
            // Do something before request is sent
            return config;
        }, error => {
            // Do something with request error
            return Promise.reject(error);
        });
        //响应拦截
        axios.interceptors.response.use(response => {
            // Do something before response is sent
            return response;
        }, error => {
            // Do something with response error
            return Promise.reject(error);
        });
        //指定请求的根路径
        // axios.defaults.baseURL = 'https://autumnfish.cn'
        axios.defaults.baseURL = 'https://www.runoob.com'
    // axios.get('/try/ajax/json_demo.json')
    
        //指定请求头
        // axios.defaults.headers
        //指定超时时间
        // axios.defaults.timeout
        axios.get('/try/ajax/json_demo.json', {
            limit: 10
        })
            .
            then(res => {
                console.log(res)
            })
            .
            catch(err => {
                console.error(err);
            })
// axios.post(url,params)
// .then(res => {
// console.log(res)
// })
// .catch(err => {
// console.error(err);
// })
// delete
// put
// patch
// all 所有请求都适配
    </script>
</body>

</html>